var Cesium = require('cesium/Cesium');
require('./css/main.css');
require('cesium/Widgets/widgets.css');
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIzYThjMTI0OC0xOTE3LTRmNGEtYjZkNS02OWNmODNkYTA5MDEiLCJpZCI6NDQ4NjQsImlhdCI6MTYxNDUyMDg2OX0.JCjqt607bGjZFbxY4yAefUjZ1AGX0uj_M2jP5XsuAII';

var viewer = new Cesium.Viewer("cesiumContainer", {
    infoBox: false,
    selectionIndicator: false,
    shadows: true,
    shouldAnimate: true
});

function createModel(url, height) {
    viewer.entities.removeAll();

    var position = Cesium.Cartesian3.fromDegrees(
        -123.0744619,
        44.0503706,
        height
    );
    var heading = Cesium.Math.toRadians(135);
    var pitch = 0;
    var roll = 0;
    var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
    var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);

    var entity = viewer.entities.add({
        name: url,
        position: position,
        orientation: orientation,
        model: {
            uri: url,
            minimumPixelSize: 128,
            maximumScale: 20000
        }
    });
    viewer.trackedEntity = entity;
}

createModel("./sampleData/models/CesiumAir/Cesium_Air.glb", 5000.0);
// createModel("./sampleData/models/CesiumDrone/CesiumDrone.glb", 150.0);
// createModel("./SampleData/models/GroundVehicle/GroundVehicle.glb", 0);